﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_bug_ViewingBug : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //lvView.Visible = false;
            if (Master.Master.CurrentUserManagement.CurrentUser.Role == (int)UserManagement.Role.Admin)
            {
                var projectNames = from item in ApplicationGlobalVariables.KillDaBugsDatabase.Projects
                                   select new
                                   {
                                       item.Name,
                                       item.ProjectId
                                   };
                if (projectNames.Any())
                    foreach (var project in projectNames)
                        ddlProjectName.Items.Add(new ListItem(project.Name, project.ProjectId.ToString()));
                else
                    ddlProjectName.Items.Add(new ListItem("Please add a project first", "-1"));
            }
            else
            {
                var projectNames = from item in ApplicationGlobalVariables.KillDaBugsDatabase.User_Projects
                                  where item.User == Master.Master.CurrentUserManagement.CurrentUser
                                  select new
                                  {
                                      item.Project.Name,
                                      item.Project.ProjectId
                                  };
                if (projectNames.Any())
                    foreach (var project in projectNames)
                        ddlProjectName.Items.Add(new ListItem(project.Name, project.ProjectId.ToString()));
                else
                    ddlProjectName.Items.Add(new ListItem("No Project assigned to you yet", "-1"));
            }
        }
    }

    protected void ddlProjectName_SelectedIndexChanged(object sender, EventArgs e)
    {
        //lvView.Visible = true;
    }
}